package util;

import java.util.List;

import pojo.User;

public class GenerateHtml {
	public static String generate(List<User> users){
		StringBuilder string = null;
		
		string = new StringBuilder("<html>"+
									"<head>"+
									"<title>Userlist</title>"+
									"</head>"+
									"<body>"+
									"<center>"+
									"<h1>User list</h1>"+
									"<table border=\"0\">"+
									"<tr>"+
									"<th>UserName</th>"+
									"<th>Salary</th>"+
									"<th>Birth</th>"+
									"<th>Sex</th>"+
									"</tr>");
		
		for(User user:users){
			string.append("<tr> <td>");
			string.append(user.getName());
			string.append("</td> <td>");
			string.append(user.getSal());
			string.append("</td> <td>");
			string.append(user.getBirth());
			string.append("</td> <td>");
			if(user.isSex()){
				string.append("male");
			}else{
				string.append("female");
			}
			string.append("</td> </tr>");
		}
		
		string.append("</table>"
					+ "</center>"
					+ "</body>"
					+ "</html>");
		
		return string.toString();
		
	}

}
